package cn.fufeiii.bt.demo.springcache;

import cn.fufeiii.bt.common.util.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author FuFei
 */
@RestController
@RequestMapping("/sc")
public class CacheController {
    @Autowired
    private CacheService cacheService;

    @GetMapping("/t1")
    public CommonResult<String> t1(String key) {
        return CommonResult.success(cacheService.randString(key));
    }

    @GetMapping("/t2")
    public CommonResult<Integer> t2(boolean flush, String key) {
        return CommonResult.success(cacheService.randInteger(flush, key));
    }

    @GetMapping("/t3")
    public CommonResult<Integer> t3(String key) {
        cacheService.removeCache(key);
        return CommonResult.success();
    }

}
